/*
 * Copyright 2011 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.paymentexpress.server.config;

import javax.servlet.http.HttpServletRequest;

/**
 * Static configuration class
 * 
 * @author pying(peng ying)
 *
 */
public class Config {

  private Config(){}
  
  //Credentials
  public static final String MERCHANT_ID = "[YOUR MERCHANT ID]";
  public static final String MERCHANT_SECRET = "[YOUR MERCHANT SECRET]";
  
  public static final String RSA_KEY = "[YOUR KEYCZAR RSA KEY]";
  public static final String RSA_KEY_META = "[YOUR KEYCZAR RSA KEY META DATA]";

  public static final String DSA_KEY = "[YOUR KEYCZAR DSA KEY]";
  public static final String DSA_KEY_META = "[YOUR KEYCZAR DSA KEY META DATA]";
  
  //Javascript source URL
  public static final String WALLET_JS_URL = "https://wallet.sandbox.google.com/online/merchant/merchant.js";
  
  //Request currency
  public static final String CURRENCY = "USD";
  
  public static String getDomain(HttpServletRequest req){
    String domain = req.getServerName();
    String protocol = req.getScheme();
    String port = Integer.toString(req.getServerPort());
    String origin = protocol + "://" + domain;
    if(!(port.equals("80") || port.equals("443"))){
      origin += ":" + port;
    }
    return origin;
  }
}
